<template>
	<uni-nav-bar title="幸运大抽奖" left-icon="left" @clickLeft="navBack" :fixed="true" statusBar></uni-nav-bar>
	<!-- <gb-choujiang :nImg='nImg' :AwardList="AwardList" :sjNum="sjNum" @updateMoney="updateMoney"></gb-choujiang> -->
	<view><q-turntable ref="turntable" @start="turntableStart" @success="turntableSuccess"></q-turntable></view>
</template>

<script setup lang="ts">
	import { ref } from 'vue';
	import { navBack } from '@/utils/navigator';
	const award = ref(1)
	const turntable = ref(null)
	const awardList = ref([
		{
			title: '特等奖'
		},
		{
			title: '一等奖'
		},
		{
			title: '二等奖'
		},
		{
			title: '三等奖'
		},
		{
			title: '四等奖'
		},
		{
			title: '啥也没有'
		}
	])
	// 用户点击开始抽奖
	function turntableStart() {
		let index = Math.floor(Math.random() * 6 + 1) //前端随机数，这里应该后台返回中奖结果
		award.value = index
		turntable.value.begin(award.value);
	}
	// 抽奖完成后操作
	function turntableSuccess() {
		const index = award.value - 1;
		console.log('bind:success', awardList.value[index]);
		uni.showToast({
			title: `恭喜你获得${awardList.value[index].title}`,
			icon: 'none'
		});
	}
</script>

<style scoped lang="less">
</style>